package com.nCoV.EpidemicSurveillance.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nCoV.EpidemicSurveillance.domain.Regist;
import com.nCoV.EpidemicSurveillance.service.UserServiceImpl;


/**
 * @author 罗穆健
 * @date 2020年4月30日
 */
@Controller
public class Login {
	
	@Autowired
	UserServiceImpl userServiceImpl;
	
//	@RequestMapping(value = "/Login")
//	public String login() {
//		// 已经登录的用户再次访问登录页面直接跳转Index
//		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
//		if(auth instanceof AnonymousAuthenticationToken){
//			return "Login";
//		}else{
//			return "design";
//		}
//	}
	
	@ResponseBody
	@RequestMapping(value="/common/regist")
	public Map<String, Object> regist(Regist regist,@RequestParam("quanxian")String quanxian) {
		return userServiceImpl.registUser(regist,quanxian);
	}
}
